package com.esisa.java.swing;

import java.util.StringTokenizer;

public class Produit implements Model{
	
		private int code;
		private String designation;
		private double prix;
		private int quantite;

	public Produit() {
		
	}

	public Produit(int code, String designation, double prix, int quantite) {
		super();
		this.code = code;
		this.designation = designation;
		this.prix = prix;
		this.quantite = quantite;
	}
	public Produit(String s) {
		StringTokenizer tk=new StringTokenizer(s,",");
		code=Integer.parseInt(tk.nextToken());
		designation=tk.nextToken();
		prix=Double.parseDouble(tk.nextToken());
		quantite=Integer.parseInt(tk.nextToken());
		
	}
	public Produit(Produit p) {
		code=p.getCode();
		designation=p.getDesignation();
		prix=p.getPrix();
		quantite=p.getQuantite();
	}
	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getDesignation() {
		return designation;
	}

	public void setDesignation(String designation) {
		this.designation = designation;
	}

	public double getPrix() {
		return prix;
	}

	public void setPrix(float prix) {
		this.prix = prix;
	}

	public int getQuantite() {
		return quantite;
	}

	public void setQuantite(int quantite) {
		this.quantite = quantite;
	}

	@Override
	public String toString() {
		return code + "," + designation + "," + prix + "," + quantite;
	}

	@Override
	public int getFieldCount() {
		// TODO Auto-generated method stub
		return 4;
	}

	@Override
	public String getFieldLabel(int index) {
		String s[]={"code","designation","prix","quantite"};
		return s[index];
	}

	@Override
	public int getFieldSize(int index) {
		int s[]={10,20,15,10};
		return s[index];
	}

	@Override
	public int getLabelWidth() {
		// TODO Auto-generated method stub
		return 100;
	}
	
	
	
}
